package com.tx.java.chapter14.exercise14_2;

/**
 * 测试class的一些方法
 */
public class Test {
    public static void main(String[] args) {
        try {

            Class clazz = Class.forName("com.tx.java.chapter14.exercise14_2.ChildClass");

            //打印类名
            for(Class c :clazz.getInterfaces()){
                System.out.println(c.getSimpleName()+"--"+c.getCanonicalName());
            }
            //getSuperClass  获得父类class
            System.out.println(clazz.getSuperclass().getSimpleName());
            Class baseClass = clazz.getSuperclass();
            try {
                //实例化对象
                clazz.newInstance();
                baseClass.newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } finally {
        }
    }
}